package com.wsx.ones.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * 说明：
 * 下面的注解功能是分三次实现业务涉及的，
 * 首先，增加的SpringBootApplication EnableEurekaClient EnableDiscoveryClient 来实现服务订阅，实现服务远程调用的功能
 * 再者，增加EnableFeignClients的功能依赖，实现feign的接口设计，实现服务的远程调用
 * 再者，增加EnableHystrix功能，实现对服务调用中产生错误，返回指定错误信息，避免服务雪崩
 * Created by wangshuaixin on 17/5/7.
 */
@SpringBootApplication
//@EnableEurekaClient
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrix
public class EurekaAppStart {

    public static void main(String[] args) {
        SpringApplication.run(EurekaAppStart.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
